//
//  MyAlbumLocation.m
//  OntheRoadV4
//
//  Created by hz on 5/20/13.
//  Copyright (c) 2013 EricHuang. All rights reserved.
//

#import "MyAlbumLocation.h"

@implementation MyAlbumLocation

- (void)dealloc
{
}

- (id) initWithCoder: (NSCoder *)coder
{
	if (self = [super init])
	{
        self.contentOffset = [[coder decodeObjectForKey:@"assetIndex"] integerValue];
        self.groupUrl = [coder decodeObjectForKey:@"groupUrl"];
	}
	return self;
}
- (void) encodeWithCoder: (NSCoder *)coder
{
    [coder encodeObject:[NSNumber numberWithInteger:self.contentOffset] forKey:@"assetIndex"];
    [coder encodeObject:self.groupUrl forKey:@"groupUrl"];
}

- (id)initWithGroupUrl:(NSString *)url contentOffset:(NSInteger)offset
{
    if (self = [super init]) {
        _contentOffset = offset;
        _groupUrl = url;
    }

    return self;
}

+ (void)setMyAlbumLocation:(MyAlbumLocation *)position
{
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    [defaults removeObjectForKey:@"MyAlbumLocation"];
    
    NSData *albumPosition = [NSKeyedArchiver archivedDataWithRootObject:position];
    [defaults setObject:albumPosition forKey:@"MyAlbumLocation_v6"];
    
    
}

+ (MyAlbumLocation *)getMyAlbumLocation
{
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSData * albumPosition = [defaults objectForKey:@"MyAlbumLocation_v6"];
    MyAlbumLocation *location = [NSKeyedUnarchiver unarchiveObjectWithData:albumPosition] ;
    return location;
    return nil;
}
@end